package com.datoucai.utils;

import com.datoucai.param.BaseResult;

/**
 * 响应工具类
 */
public class BaseResultUtils {

	/**
	 * 成功
	 * @param t
	 * @return
	 * @param <T>
	 */
	public static <T> BaseResult<T> generateSuccess(T t) {
		BaseResult<T> result = new BaseResult<>();
		result.setCode(0);
		result.setSuccess(true);
		result.setMsg("操作成功");
		result.setData(t);
		return result;
	}

	/**
	 * 失败
	 * @param msg
	 * @return
	 */
	public static BaseResult generateFail(String msg) {
		BaseResult result = new BaseResult<>();
		result.setCode(-1);
		result.setSuccess(false);
		result.setMsg(msg);
		result.setData(null);
		return result;
	}
}
